
$(function() {
	_change("input[id='bank']:visible", "select[id='bank_t']:visible");
	
	// Tip.emp('员工');
	
	$("input[id^='emp']:visible").autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: 'emp.php?do=Emp.ajax_zjm',
				dataType: "json",
				data: {
					featureClass: "P",
					style: "full",
					maxRows: 30,
					q: request.term
				},
				success: function( data ) {
					response( $.map( data, function( item ) {
						return {
							name: item.name,
							label: item.name + " [" + item.zjm + ", " + item.dept_t + "]",
							value: item.id + ":" + item.name
						}
					}));
				}
			});
		},
		
		select: function( event, ui ) {
			$("#name").val(ui.item.name);
		},
		
		minLength: 1
	});
	
	$.extend({
		format: function(str, step, splitor) {
			str = str.toString();
			var len = str.length;
 
			if (len > step) {
				var i = 0, s = "", arr = [];
				while (i < len) {
					s = str.substr(i, step);					
					arr.push(s);					
					i += step;					
				}				 
				 
				str = arr.join(splitor);
			 }
			
			 return str;
		}
	});
	
	$("input[id='code']:visible").keyup(function() {
		var s = $(this).val();
		// alert(s);
		var a = s.replace(/\s/g, '');
		
		var b = $.format(a, 4, ' ');
		//$(this).val(b);
		$("#code_t").html(b);
	});
});
